//
//  ViewController.swift
//  下拉刷新
//
//  Created by ming on 16/10/17.
//  Copyright © 2016年 ming. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    lazy var v:LGRefreshControl = LGRefreshControl()

    @IBOutlet weak var tableView: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
 
             tableView.contentInset = UIEdgeInsets(top: 64, left: 0, bottom: 0, right: 0)
     
     
       tableView.addSubview(v)
           v.beginRefreshing()
       
        v.addTarget(self, action: #selector(loadData), for: .valueChanged)
   
        loadData()
        
    }
    func loadData(){
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            
            //数据加载完毕
            self.v.endRefreshing()
        }
        
    }
   

}

